/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bookstore.service;

import bookstore.idao.ICustomerDao;
import bookstore.iservice.ICustomerService;
import bookstore.model.Customer;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class CustomerService implements ICustomerService {
    
    private ICustomerDao customerDao;
    
    @Override
    public void setCustomerDao(ICustomerDao customerDao) {
        this.customerDao = customerDao;
    }
    
    @Override
    public void addCustomer(Customer customer) {
        customerDao.insert(customer);
    }
    
    @Override
    public void editCustomer(Customer customer) {
        customerDao.update(customer);
    }

    @Override
    public void editMessage(Customer customer) {
        customerDao.updateMessage(customer);
    }

    @Override
    public void editPassword(Customer customer) {
        customerDao.updatePassword(customer);
    }

    @Override
    public void deleteCustomer(Integer id) {
        customerDao.delete(id);
    }
    
    @Override
    public Customer findCustomerById(Integer id) {
        return customerDao.findById(id);
    }
    
    @Override
    public Customer findCustomerByNameAndPassword(String name, String password) {
        return customerDao.find(name, password);
    }
    
    @Override
    public List<Customer> findAllCustomersByPage(Integer pageSize, Integer pageNo) {
        return customerDao.findByPage(pageSize, pageNo);
    }
    
    @Override
    public Integer findCount() {
        return customerDao.findAllCount();
    }
}
